package view;

import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.ListModel;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;

import model.container.CursistenException;
import controller.InschrijvingController;
import controller.OpstartController;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI Builder, which is free
 * for non-commercial use. If Jigloo is being used commercially (ie, by a corporation, company or
 * business for any purpose whatever) then you should purchase a license for each developer using
 * Jigloo. Please visit www.cloudgarden.com for details. Use of Jigloo implies acceptance of these
 * licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS
 * CODE CANNOT BE USED LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class InschrijvingenFrame extends javax.swing.JFrame {

	private final Color achtergrond = new Color(228, 183, 27);
	private static int loginTabIndex = 0;
	private static int personaliaTabIndex = 1;
	private static int cursussenTabIndex = 2;
	private static int rekeningTabIndex = 3;
	private final OpstartController opstrtController;
	private final InschrijvingController inschrController;
	private JTabbedPane keuzePanel;
	private final JPanel login;
	private final JPanel personalia;
	private final JPanel cursusKeuze;
	private final JPanel rekeningOverzicht;
	private JTextField jTextFieldVariabel1;
	private JLabel jLabelTypeCursist;
	private JTextField jTextFieldVariabel2;
	private JTextField jTextFieldNaam;
	private JTextField jTextFieldNummer;
	private JLabel jLabelVariabel2;
	private JLabel jLabelVariabel1;
	private JLabel jLabelNaam;
	private JLabel jLabelCursistNummer;
	private JRadioButton jRadioButtonHerscholingsCursist;
	private JRadioButton jRadioButtonVrijeCursist;
	private JButton jButtonProceed;
	private JLabel JLabelBestaandeCursisten;
	private JLabel JLabelCursistKeuze;
	private JRadioButton jRadioButtonBestaandeCursist;
	private JLabel jLabelNummer;
	private JButton jButtonUitschrijven;
	private JButton jButtonInschrijvenVoorCursus;
	private JList jListIngeschrevencursussen;
	private JLabel jLabel2;
	private JList jListAangebodenCursussen;
	private JLabel JLabelAangebodenCursussen;
	private JList jListBestaandeCursisten;
	private JButton jButtonOpslaan;
	private JRadioButton jRadioButtonNieuweCursist;

	public InschrijvingenFrame(OpstartController opstartController, InschrijvingController inschrijvingController) {
		super();
		this.opstrtController = opstartController;
		this.inschrController = inschrijvingController;
		// [start] Login Panel
		login = new JPanel();
		GroupLayout cursistLoginLayout = new GroupLayout(login);
		login.setLayout(cursistLoginLayout);
		login.setBackground(achtergrond);
		{
			jButtonProceed = new JButton();
			jButtonProceed.setText("Verder");
			jButtonProceed.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent evt) {
					jButtonProceedActionPerformed(evt);
				}
			});
		}
		{
			ListModel jListBestaandeCursistenModel = new DefaultComboBoxModel(inschrController.getCursistenLijst());
			jListBestaandeCursisten = new JList();
			jListBestaandeCursisten.setModel(jListBestaandeCursistenModel);
		}
		{
			jRadioButtonNieuweCursist = new JRadioButton();
			jRadioButtonNieuweCursist.setBackground(achtergrond);
			jRadioButtonNieuweCursist.setText("Nieuwe Cursist");
			jRadioButtonNieuweCursist.addItemListener(new ItemListener() {
				@Override
				public void itemStateChanged(ItemEvent evt) {
					jRadioButtonNieuweCursistItemStateChanged(evt);
				}
			});
		}
		{
			jRadioButtonBestaandeCursist = new JRadioButton();
			jRadioButtonBestaandeCursist.setBackground(achtergrond);
			jRadioButtonBestaandeCursist.setText("Bestaande Cursist");
			jRadioButtonBestaandeCursist.addItemListener(new ItemListener() {
				@Override
				public void itemStateChanged(ItemEvent evt) {
					jRadioButtonBestaandeCursistItemStateChanged(evt);
				}
			});
		}
		{
			JLabelCursistKeuze = new JLabel();
			JLabelCursistKeuze
					.setText("Wil je een nieuwe cursist toevoegen of wil je verder werken met een bestaande?");
		}
		{
			JLabelBestaandeCursisten = new JLabel();
			JLabelBestaandeCursisten.setText("Selecteer de gewenste cursist.");
		}
		// [start] Layout
		cursistLoginLayout.setVerticalGroup(cursistLoginLayout
				.createSequentialGroup()
				.addContainerGap(60, 60)
				.addComponent(JLabelCursistKeuze, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addGroup(
						cursistLoginLayout
								.createParallelGroup(GroupLayout.Alignment.BASELINE)
								.addComponent(jRadioButtonNieuweCursist, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)
								.addComponent(jRadioButtonBestaandeCursist, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)).addGap(56)
				.addComponent(JLabelBestaandeCursisten, GroupLayout.PREFERRED_SIZE, 11, GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(jListBestaandeCursisten, GroupLayout.PREFERRED_SIZE, 170, GroupLayout.PREFERRED_SIZE)
				.addGap(37).addComponent(jButtonProceed, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
				.addContainerGap(254, Short.MAX_VALUE));
		cursistLoginLayout
				.setHorizontalGroup(cursistLoginLayout
						.createSequentialGroup()
						.addContainerGap(57, 57)
						.addGroup(
								cursistLoginLayout
										.createParallelGroup()
										.addGroup(
												GroupLayout.Alignment.LEADING,
												cursistLoginLayout
														.createSequentialGroup()
														.addComponent(JLabelCursistKeuze, GroupLayout.PREFERRED_SIZE,
																436, GroupLayout.PREFERRED_SIZE)
														.addGap(0, 40, Short.MAX_VALUE))
										.addGroup(
												GroupLayout.Alignment.LEADING,
												cursistLoginLayout
														.createSequentialGroup()
														.addGroup(
																cursistLoginLayout
																		.createParallelGroup()
																		.addComponent(jButtonProceed,
																				GroupLayout.Alignment.LEADING, 0, 200,
																				Short.MAX_VALUE)
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistLoginLayout
																						.createSequentialGroup()
																						.addComponent(
																								jRadioButtonNieuweCursist,
																								GroupLayout.PREFERRED_SIZE,
																								118,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(0, 82, Short.MAX_VALUE))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistLoginLayout
																						.createSequentialGroup()
																						.addComponent(
																								JLabelBestaandeCursisten,
																								GroupLayout.PREFERRED_SIZE,
																								166,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(0, 34, Short.MAX_VALUE)))
														.addComponent(jRadioButtonBestaandeCursist,
																GroupLayout.PREFERRED_SIZE, 123,
																GroupLayout.PREFERRED_SIZE).addGap(153))
										.addGroup(
												cursistLoginLayout
														.createSequentialGroup()
														.addComponent(jListBestaandeCursisten,
																GroupLayout.PREFERRED_SIZE, 476,
																GroupLayout.PREFERRED_SIZE)
														.addGap(0, 0, Short.MAX_VALUE))).addContainerGap(196, 196));
		// [end]
		// [end]
		// [start] Personalia Panel
		personalia = new JPanel();
		GroupLayout cursistGegevensLayout = new GroupLayout(personalia);
		personalia.setLayout(cursistGegevensLayout);
		personalia.setBackground(achtergrond);
		{
			jRadioButtonVrijeCursist = new JRadioButton();
			jRadioButtonVrijeCursist.setBackground(achtergrond);
			jRadioButtonVrijeCursist.setText("Vrije Cursist");
			jRadioButtonVrijeCursist.addItemListener(new ItemListener() {
				@Override
				public void itemStateChanged(ItemEvent evt) {
					jRadioButtonVrijeCursistItemStateChanged(evt);
				}
			});
		}
		{
			jRadioButtonHerscholingsCursist = new JRadioButton();
			jRadioButtonHerscholingsCursist.setBackground(achtergrond);
			jRadioButtonHerscholingsCursist.setText("Herscholingscursist");
			jRadioButtonHerscholingsCursist.addItemListener(new ItemListener() {
				@Override
				public void itemStateChanged(ItemEvent evt) {
					JRadioButtonHerscholingsCursistItemStateChanged(evt);
				}
			});
		}
		{
			jLabelTypeCursist = new JLabel();
			jLabelTypeCursist.setText("Type Cursist");
		}
		{
			jLabelNummer = new JLabel();
			jLabelNummer.setText("Nummer");
		}
		{
			jLabelCursistNummer = new JLabel();
			jLabelCursistNummer.setText("Nummer");
		}
		{
			jTextFieldNummer = new JTextField();
			jTextFieldNummer.setEnabled(false);
		}
		{
			jLabelNaam = new JLabel();
			jLabelNaam.setText("Naam");
		}
		{
			jTextFieldNaam = new JTextField();
		}
		{
			jLabelVariabel1 = new JLabel();
			jLabelVariabel1.setText("Var1");
			jLabelVariabel1.setVisible(false);
		}
		{
			jTextFieldVariabel1 = new JTextField();
			jTextFieldVariabel1.setVisible(false);
		}
		{
			jLabelVariabel2 = new JLabel();
			jLabelVariabel2.setText("Var2");
			jLabelVariabel2.setVisible(false);
		}
		{
			jTextFieldVariabel2 = new JTextField();
			jTextFieldVariabel2.setVisible(false);
		}
		{
			jButtonOpslaan = new JButton();
			jButtonOpslaan.setText("Wijzigingen Opslaan");
			jButtonOpslaan.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent evt) {
					try {
						jButtonOpslaanActionPerformed(evt);
					} catch (CloneNotSupportedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (CursistenException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			});
		}
		// [start] Layout
		cursistGegevensLayout
				.setHorizontalGroup(cursistGegevensLayout
						.createSequentialGroup()
						.addContainerGap(23, 23)
						.addGroup(
								cursistGegevensLayout
										.createParallelGroup()
										.addGroup(
												GroupLayout.Alignment.LEADING,
												cursistGegevensLayout
														.createSequentialGroup()
														.addComponent(jButtonOpslaan, GroupLayout.PREFERRED_SIZE, 385,
																GroupLayout.PREFERRED_SIZE)
														.addGap(0, 6, Short.MAX_VALUE))
										.addGroup(
												cursistGegevensLayout
														.createSequentialGroup()
														.addGroup(
																cursistGegevensLayout
																		.createParallelGroup()
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistGegevensLayout
																						.createSequentialGroup()
																						.addPreferredGap(
																								LayoutStyle.ComponentPlacement.RELATED,
																								0, Short.MAX_VALUE)
																						.addComponent(
																								jLabelTypeCursist,
																								GroupLayout.PREFERRED_SIZE,
																								93,
																								GroupLayout.PREFERRED_SIZE))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistGegevensLayout
																						.createSequentialGroup()
																						.addComponent(
																								jLabelNaam,
																								GroupLayout.PREFERRED_SIZE,
																								93,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(6))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistGegevensLayout
																						.createSequentialGroup()
																						.addComponent(
																								jLabelVariabel1,
																								GroupLayout.PREFERRED_SIZE,
																								93,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(6))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistGegevensLayout
																						.createSequentialGroup()
																						.addComponent(
																								jLabelVariabel2,
																								GroupLayout.PREFERRED_SIZE,
																								93,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(6))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistGegevensLayout
																						.createSequentialGroup()
																						.addComponent(
																								jLabelNummer,
																								GroupLayout.PREFERRED_SIZE,
																								GroupLayout.PREFERRED_SIZE,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(0, 62, Short.MAX_VALUE)))
														.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
														.addGroup(
																cursistGegevensLayout
																		.createParallelGroup()
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistGegevensLayout
																						.createSequentialGroup()
																						.addComponent(
																								jTextFieldVariabel2,
																								GroupLayout.PREFERRED_SIZE,
																								230,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(50))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistGegevensLayout
																						.createSequentialGroup()
																						.addComponent(
																								jTextFieldNaam,
																								GroupLayout.PREFERRED_SIZE,
																								230,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(50))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistGegevensLayout
																						.createSequentialGroup()
																						.addComponent(
																								jTextFieldNummer,
																								GroupLayout.PREFERRED_SIZE,
																								230,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(50))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistGegevensLayout
																						.createSequentialGroup()
																						.addComponent(
																								jTextFieldVariabel1,
																								GroupLayout.PREFERRED_SIZE,
																								230,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(50))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursistGegevensLayout
																						.createSequentialGroup()
																						.addComponent(
																								jRadioButtonVrijeCursist,
																								GroupLayout.PREFERRED_SIZE,
																								107,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(44)
																						.addComponent(
																								jRadioButtonHerscholingsCursist,
																								GroupLayout.PREFERRED_SIZE,
																								129,
																								GroupLayout.PREFERRED_SIZE)))))
						.addContainerGap(315, 315));
		cursistGegevensLayout.linkSize(SwingConstants.HORIZONTAL, new Component[] { jLabelVariabel2, jLabelVariabel1,
				jLabelNaam });
		cursistGegevensLayout.setVerticalGroup(cursistGegevensLayout
				.createSequentialGroup()
				.addContainerGap(56, 56)
				.addGroup(
						cursistGegevensLayout
								.createParallelGroup(GroupLayout.Alignment.BASELINE)
								.addComponent(jRadioButtonVrijeCursist, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)
								.addComponent(jRadioButtonHerscholingsCursist, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)
								.addComponent(jLabelTypeCursist, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE))
				.addGap(38)
				.addGroup(
						cursistGegevensLayout
								.createParallelGroup(GroupLayout.Alignment.BASELINE)
								.addComponent(jTextFieldNummer, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)
								.addComponent(jLabelNummer, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addGap(20)
				.addGroup(
						cursistGegevensLayout
								.createParallelGroup(GroupLayout.Alignment.BASELINE)
								.addComponent(jTextFieldNaam, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)
								.addComponent(jLabelNaam, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addGap(21)
				.addGroup(
						cursistGegevensLayout
								.createParallelGroup(GroupLayout.Alignment.BASELINE)
								.addComponent(jTextFieldVariabel1, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)
								.addComponent(jLabelVariabel1, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE))
				.addGap(17)
				.addGroup(
						cursistGegevensLayout
								.createParallelGroup(GroupLayout.Alignment.BASELINE)
								.addComponent(jTextFieldVariabel2, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE)
								.addComponent(jLabelVariabel2, GroupLayout.Alignment.BASELINE,
										GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
										GroupLayout.PREFERRED_SIZE))
				.addGap(54)
				.addComponent(jButtonOpslaan, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE).addContainerGap(348, Short.MAX_VALUE));
		// [end]
		// [end]
		// [start] Cursussen Panel
		cursusKeuze = new JPanel();
		GroupLayout cursusKeuzeLayout = new GroupLayout(cursusKeuze);
		cursusKeuze.setLayout(cursusKeuzeLayout);
		rekeningOverzicht = new JPanel();
		cursusKeuze.setBackground(new java.awt.Color(228, 183, 27));
		{
			JLabelAangebodenCursussen = new JLabel();
			JLabelAangebodenCursussen.setText("Aangeboden Cursussen");
		}
		{
			ListModel jListAangebodenCursussenModel = new DefaultComboBoxModel(
					inschrController.getBeschikbareCursussenLijst());
			jListAangebodenCursussen = new JList();
			jListAangebodenCursussen.setModel(jListAangebodenCursussenModel);
		}
		{
			jLabel2 = new JLabel();
			jLabel2.setText("Ingeschreven Cursussen");
		}
		{
			ListModel jListIngeschrevenCursussenModel = new DefaultComboBoxModel(
					inschrController.getIngeschrevenCursussenLijst());
			jListIngeschrevencursussen = new JList();
			jListIngeschrevencursussen.setModel(jListIngeschrevenCursussenModel);
		}
		{
			jButtonInschrijvenVoorCursus = new JButton();
			jButtonInschrijvenVoorCursus.setText("Inschrijven");
			jButtonInschrijvenVoorCursus.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent evt) {
					jButtonInschrijvenVoorCursusActionPerformed(evt);
				}
			});
		}
		{
			jButtonUitschrijven = new JButton();
			jButtonUitschrijven.setText("Uitschrijven");
			jButtonUitschrijven.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent evt) {
					jButtonUitschrijvenActionPerformed(evt);
				}
			});
		}
		cursusKeuzeLayout.setVerticalGroup(cursusKeuzeLayout
				.createSequentialGroup()
				.addContainerGap(34, 34)
				.addComponent(JLabelAangebodenCursussen, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addComponent(jListAangebodenCursussen, GroupLayout.PREFERRED_SIZE, 174, GroupLayout.PREFERRED_SIZE)
				.addGap(33)
				.addGroup(
						cursusKeuzeLayout
								.createParallelGroup()
								.addComponent(jButtonInschrijvenVoorCursus, GroupLayout.Alignment.LEADING,
										GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE)
								.addComponent(jButtonUitschrijven, GroupLayout.Alignment.LEADING,
										GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE))
				.addGap(25)
				.addComponent(jLabel2, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
						GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addComponent(jListIngeschrevencursussen, GroupLayout.PREFERRED_SIZE, 174, GroupLayout.PREFERRED_SIZE)
				.addContainerGap(166, Short.MAX_VALUE));
		cursusKeuzeLayout
				.setHorizontalGroup(cursusKeuzeLayout
						.createSequentialGroup()
						.addContainerGap(31, 31)
						.addGroup(
								cursusKeuzeLayout
										.createParallelGroup()
										.addGroup(
												cursusKeuzeLayout
														.createSequentialGroup()
														.addComponent(jListAangebodenCursussen,
																GroupLayout.PREFERRED_SIZE, 596,
																GroupLayout.PREFERRED_SIZE)
														.addGap(0, 0, Short.MAX_VALUE))
										.addGroup(
												cursusKeuzeLayout
														.createSequentialGroup()
														.addComponent(jListIngeschrevencursussen,
																GroupLayout.PREFERRED_SIZE, 596,
																GroupLayout.PREFERRED_SIZE)
														.addGap(0, 0, Short.MAX_VALUE))
										.addGroup(
												GroupLayout.Alignment.LEADING,
												cursusKeuzeLayout
														.createSequentialGroup()
														.addGroup(
																cursusKeuzeLayout
																		.createParallelGroup()
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursusKeuzeLayout
																						.createSequentialGroup()
																						.addGap(100)
																						.addComponent(
																								jButtonInschrijvenVoorCursus,
																								GroupLayout.PREFERRED_SIZE,
																								178,
																								GroupLayout.PREFERRED_SIZE))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursusKeuzeLayout
																						.createSequentialGroup()
																						.addComponent(
																								JLabelAangebodenCursussen,
																								GroupLayout.PREFERRED_SIZE,
																								140,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(138))
																		.addGroup(
																				GroupLayout.Alignment.LEADING,
																				cursusKeuzeLayout
																						.createSequentialGroup()
																						.addComponent(
																								jLabel2,
																								GroupLayout.PREFERRED_SIZE,
																								140,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(138)))
														.addGap(57)
														.addComponent(jButtonUitschrijven, GroupLayout.PREFERRED_SIZE,
																178, GroupLayout.PREFERRED_SIZE)
														.addGap(0, 83, Short.MAX_VALUE))).addContainerGap(102, 102));
		// [end]
		rekeningOverzicht.setBackground(new java.awt.Color(228, 183, 27));

		initGUI();
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			GroupLayout thisLayout = new GroupLayout(getContentPane());
			this.setPreferredSize(new java.awt.Dimension(750, 755));
			{
				getContentPane().setLayout(thisLayout);
				getContentPane().setBackground(achtergrond);
				this.addWindowListener(new WindowAdapter() {
					@Override
					public void windowClosing(WindowEvent evt) {
						thisWindowClosing(evt);
					}
				});
				// Initialiseren van panels
				keuzePanel = new JTabbedPane();
				keuzePanel.setSize(734, 717);
				keuzePanel.setBackground(achtergrond);
				keuzePanel.add(login, InschrijvingenFrame.loginTabIndex);
				keuzePanel.add(personalia, InschrijvingenFrame.personaliaTabIndex);
				keuzePanel.add(cursusKeuze, InschrijvingenFrame.cursussenTabIndex);
				keuzePanel.add(rekeningOverzicht, InschrijvingenFrame.rekeningTabIndex);
				keuzePanel.setTitleAt(loginTabIndex, "Login");
				keuzePanel.setTitleAt(personaliaTabIndex, "Personalia");
				keuzePanel.setTitleAt(cursussenTabIndex, "Cursussen");
				keuzePanel.setTitleAt(rekeningTabIndex, "Rekeningoverzicht");
				// opstartstatus componenenten wijzigen
				keuzePanel.setEnabledAt(InschrijvingenFrame.loginTabIndex, true);
				keuzePanel.setEnabledAt(InschrijvingenFrame.personaliaTabIndex, false);
				keuzePanel.setEnabledAt(InschrijvingenFrame.cursussenTabIndex, false);
				keuzePanel.setEnabledAt(InschrijvingenFrame.rekeningTabIndex, false);
				this.jListBestaandeCursisten.setEnabled(false);
				thisLayout.setVerticalGroup(thisLayout.createSequentialGroup().addComponent(keuzePanel,
						GroupLayout.PREFERRED_SIZE, 717, GroupLayout.PREFERRED_SIZE));
				thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup().addComponent(keuzePanel,
						GroupLayout.PREFERRED_SIZE, 734, GroupLayout.PREFERRED_SIZE));
			}
			pack();
			this.setSize(750, 755);
		} catch (Exception e) {
			// add your error handling code here
			e.printStackTrace();
		}
	}

	// [start] Login Methods
	private void jRadioButtonNieuweCursistItemStateChanged(ItemEvent evt) {
		// System.out.println("jRadioButtonNieuweCursist.itemStateChanged, event=" + evt);
		if (this.jRadioButtonNieuweCursist.isSelected()) {
			this.jRadioButtonBestaandeCursist.setSelected(false);
			this.jListBestaandeCursisten.clearSelection();
			this.jListBestaandeCursisten.setEnabled(false);
		}
	}

	private void jRadioButtonBestaandeCursistItemStateChanged(ItemEvent evt) {
		// System.out.println("jRadioButtonBestaandeCursist.itemStateChanged, event=" + evt);
		if (this.jRadioButtonBestaandeCursist.isSelected()) {
			this.jRadioButtonNieuweCursist.setSelected(false);
			this.jListBestaandeCursisten.setEnabled(true);

		}
	}

	private void jButtonProceedActionPerformed(ActionEvent evt) {
		// System.out.println("jButtonProceed.actionPerformed, event=" + evt);
		boolean validAction = false;
		if (this.jRadioButtonNieuweCursist.isSelected()) {
			validAction = true;
			this.keuzePanel.setEnabledAt(personaliaTabIndex, true);
			this.keuzePanel.setSelectedIndex(personaliaTabIndex);
		} else if (this.jRadioButtonBestaandeCursist.isSelected()) {
			if (!this.jListBestaandeCursisten.isSelectionEmpty()) {

				this.keuzePanel.setEnabledAt(personaliaTabIndex, true);
				this.keuzePanel.setEnabledAt(cursussenTabIndex, true);
				this.keuzePanel.setEnabledAt(rekeningTabIndex, true);
				this.keuzePanel.setSelectedIndex(cursussenTabIndex);
				validAction = true;
			} else {
				IO.toonStringMetVenster("Gelieve een cursist te selecteren!!");
				validAction = false;
			}
		} else {
			IO.toonStringMetVenster("Gelieve een type cursist te selecteren!!");
			validAction = false;
		}
		this.keuzePanel.setEnabledAt(loginTabIndex, !validAction);
		laadCursistData();
	}

	// [end]

	// [start] Personalia Methods
	private void laadCursistData() {
		if (this.jRadioButtonBestaandeCursist.isSelected() && !(this.jListBestaandeCursisten.isSelectionEmpty())) {
			String[] selectedItemSplitted = this.jListBestaandeCursisten.getSelectedValue().toString().split(" ");
			int cursistIndex = Integer.parseInt(selectedItemSplitted[0]);
			this.inschrController.ladenVanCursist(cursistIndex);
		}
		jRadioButtonVrijeCursist.setSelected(this.inschrController.isVrijeCursist());
		jRadioButtonHerscholingsCursist.setSelected(this.inschrController.isHerscholingsCursist());
		this.jTextFieldNummer.setText(Integer.toString(this.inschrController.getCursistNummer()));
		this.jTextFieldNaam.setText(this.inschrController.getCursistNaam());
		if (this.inschrController.isVrijeCursist()) {
			this.jLabelVariabel1.setText("Nationaliteit");
			this.jLabelVariabel1.setVisible(true);
			this.jTextFieldVariabel1.setVisible(true);
			this.jTextFieldVariabel1.setText(this.inschrController.getVar1());
		} else if (this.inschrController.isHerscholingsCursist()) {
			this.jLabelVariabel1.setText("Hoogste Diploma");
			this.jLabelVariabel1.setVisible(true);
			this.jTextFieldVariabel1.setVisible(true);
			this.jTextFieldVariabel1.setText(this.inschrController.getVar1());
			this.jLabelVariabel2.setText("Reden Herscholing");
			this.jLabelVariabel2.setVisible(true);
			this.jTextFieldVariabel2.setVisible(true);
			this.jTextFieldVariabel2.setText(this.inschrController.getVar2());
		}
	}

	private void jRadioButtonVrijeCursistItemStateChanged(ItemEvent evt) {
		// System.out.println("jRadioButtonVrijeCursist.itemStateChanged, event="+evt);
		if (jRadioButtonVrijeCursist.isSelected()) {
			this.jRadioButtonHerscholingsCursist.setSelected(false);
			this.jLabelVariabel1.setText("Nationaliteit");
			this.jLabelVariabel1.setVisible(true);
			this.jTextFieldVariabel1.setVisible(true);
			this.jTextFieldVariabel1.setText("");
			this.jLabelVariabel2.setText("Var 2");
			this.jLabelVariabel2.setVisible(false);
			this.jTextFieldVariabel2.setVisible(false);
			this.jTextFieldVariabel2.setText("");
		}
	}

	private void JRadioButtonHerscholingsCursistItemStateChanged(ItemEvent evt) {

		// System.out.println("JRadioButtonHerscholingsCursist.itemStateChanged, event="+evt);
		if (jRadioButtonHerscholingsCursist.isSelected()) {
			this.jRadioButtonVrijeCursist.setSelected(false);
			this.jLabelVariabel1.setText("Hoogste Diploma");
			this.jLabelVariabel1.setVisible(true);
			this.jTextFieldVariabel1.setVisible(true);
			this.jTextFieldVariabel1.setText("");
			this.jLabelVariabel2.setText("Reden Herscholing");
			this.jLabelVariabel2.setVisible(true);
			this.jTextFieldVariabel2.setVisible(true);
			this.jTextFieldVariabel2.setText("");
		}
	}

	private void jButtonOpslaanActionPerformed(ActionEvent evt) throws CloneNotSupportedException, CursistenException {
		System.out.println("jButtonOpslaan.actionPerformed, event=" + evt);
		if (jRadioButtonVrijeCursist.isSelected()) {
			int CursistNummer = Integer.parseInt(this.jTextFieldNummer.getText());
			String CursistNaam = this.jTextFieldNaam.getText();
			String Nationaliteit = this.jTextFieldVariabel1.getText();
			if ((CursistNaam != "") && (Nationaliteit != "")) {
				this.inschrController.RegistreerCursist(CursistNummer, CursistNaam, Nationaliteit);
			} else {
				IO.toonStringMetVenster("Gelieve alle velden te controleren");
			}
		} else if (jRadioButtonHerscholingsCursist.isSelected()) {
			int CursistNummer = Integer.parseInt(this.jTextFieldNummer.getText());
			String CursistNaam = this.jTextFieldNaam.getText();
			String hoogsteDiploma = this.jTextFieldVariabel1.getText();
			String redenHerscholing = this.jTextFieldVariabel2.getText();
			if ((CursistNaam != "") && (hoogsteDiploma != "") || (redenHerscholing != "")) {
				this.inschrController.RegistreerCursist(CursistNummer, CursistNaam, hoogsteDiploma, redenHerscholing);
			} else {
				IO.toonStringMetVenster("Gelieve alle velden te controleren");
			}
		}
	}

	// [end]

	// [start] cursusKeuze Methods
	private void jButtonInschrijvenVoorCursusActionPerformed(ActionEvent evt) {
		System.out.println("jButtonInschrijvenVoorCursus.actionPerformed, event=" + evt);
		if (!this.jListAangebodenCursussen.isSelectionEmpty()) {
			String[] selectedCourse = this.jListAangebodenCursussen.getSelectedValue().toString().split(" ");
			int selectedCourseIndex = Integer.parseInt(selectedCourse[1]);
			this.inschrController.RegistreerInschrijving(selectedCourseIndex);
		}
		ListModel jListUpdatedAangebodenCursussenModel = new DefaultComboBoxModel(
				inschrController.getBeschikbareCursussenLijst());
		ListModel jListUpdatedInschrCursussenModel = new DefaultComboBoxModel(
				inschrController.getIngeschrevenCursussenLijst());
		this.jListAangebodenCursussen.setModel(jListUpdatedAangebodenCursussenModel);
		this.jListIngeschrevencursussen.setModel(jListUpdatedInschrCursussenModel);

	}

	private void jButtonUitschrijvenActionPerformed(ActionEvent evt) {
		System.out.println("jButtonUitschrijven.actionPerformed, event=" + evt);
		if (!this.jListIngeschrevencursussen.isSelectionEmpty()) {
			String[] selectedCourse = this.jListIngeschrevencursussen.getSelectedValue().toString().split(" ");
			int selectedCourseIndex = Integer.parseInt(selectedCourse[1]);
			this.inschrController.VerwijderInschrijving(selectedCourseIndex);
		}
		ListModel jListUpdatedAangebodenCursussenModel = new DefaultComboBoxModel(
				inschrController.getBeschikbareCursussenLijst());
		ListModel jListUpdatedInschrCursussenModel = new DefaultComboBoxModel(
				inschrController.getIngeschrevenCursussenLijst());
		this.jListAangebodenCursussen.setModel(jListUpdatedAangebodenCursussenModel);
		this.jListIngeschrevencursussen.setModel(jListUpdatedInschrCursussenModel);
	}

	// [end]

	private void thisWindowClosing(WindowEvent evt) {
		// System.out.println("this.windowClosing, event=" + evt);
		this.setVisible(false);
		opstrtController.execute();
	}

}
